- content_for :title_header do
  %h1= t(".edit_listing")

- content_for :extra_javascript do
  :javascript
    $(document).ready(function() {
      window.ST.initialize_edit_listing_form_selectors("#{I18n.locale}", #{@listing_presenter.category_tree.to_json.html_safe}, #{@listing_presenter.listing_form_menu_titles().to_json.html_safe}, #{@listing_presenter.category_id.to_json.html_safe}, #{@listing_presenter.subcategory_id.to_json.html_safe}, #{@listing.listing_shape_id.to_json.html_safe}, #{@listing.id});
    });

- content_for :extra_javascript do
  - maps_key = MarketplaceHelper.google_maps_key(@current_community.id)
  - key_param = maps_key ? "?key=#{maps_key}" : ""
  - needs_maps = !FeatureFlagHelper.feature_enabled?(:topbar_v1) || search_mode == :keyword
  = javascript_include_tag "//maps.googleapis.com/maps/api/js#{key_param}" if needs_maps

#new_listing_form.new-listing-form.centered-section

  #selected-groups

    - if @listing_presenter.categories.size > 1
      .selected-group{:name => "category"}
        - @listing_presenter.categories.each do |value|
          %a.select.selected.hidden{:data => {:id => value.id}}
            .link-text= t("listings.new.selected_category", :category => value.display_name(I18n.locale))

    - if @listing_presenter.subcategories.size > 1
      .selected-group{:name => "subcategory"}
        - @listing_presenter.subcategories.each do |value|
          %a.select.selected.hidden{:data => {:id => value.id}}
            .link-text= t("listings.new.selected_subcategory", :subcategory => value.display_name(I18n.locale))

    - if @listing_presenter.shapes.size > 1
      .selected-group{:name => "listing_shape"}
        - @listing_presenter.shapes.each do |value|
          %a.select.selected.hidden{:data => {:id => value[:id]}}
            .link-text= t("listings.new.selected_transaction_type", :transaction_type => t(value[:name_tr_key]))

  %h2.listing-form-title{:id => "foo"}

  #option-groups

    - if @listing_presenter.categories.size > 1
      .option-group{:name => "category"}
        - @listing_presenter.categories.each do |value|
          %a.select.option.hidden{:data => {:id => value.id}}
            .link-text= value.display_name(I18n.locale)

    - if @listing_presenter.subcategories.size > 1
      .option-group{:name => "subcategory"}
        - @listing_presenter.subcategories.each do |value|
          %a.select.option.hidden{:data => {:id => value.id}}
            .link-text= value.display_name(I18n.locale)

    - if @listing_presenter.shapes.size > 1
      .option-group{:name => "listing_shape"}
        - @listing_presenter.shapes.each do |value|
          %a.select.option.hidden{:data => {:id => value[:id]}}
            .link-text= t(value[:name_tr_key])

  .js-form-fields.hidden

    - if form_content

      = render partial: "listings/form/form_content", locals: form_content.merge(run_js_immediately: false)

